/**
 * Copyright 2015-2016 eyaomall.cn
 * All rights reserved.
 *
 * @project
 * @author pro
 * @version 1.0
 * @date 2016-03-07
 */
package com.eyaomall.wxmall.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eyaomall.wxmall.common.helper.AreaHelper;
import com.lycheeframework.core.cmp.api.http.ApiData;
import com.lycheeframework.core.cmp.api.http.ApiResponse;

@Controller
@RequestMapping("area")
/**
 * 区域资源
 * @author pro
 *
 */
public class AreaController {

	/**
	 * 查询所有的省份信息
	 * @return
	 */
	@RequestMapping("list_province")
	public @ResponseBody ApiData listProvince(){
		return ApiResponse.toData(AreaHelper.getProvinces());
	}
	
	/**
	 * 根据省份ID获取城市数据
	 * @param provinceId
	 * @return
	 */
	@RequestMapping("list_city")
	public @ResponseBody ApiData listCityByProvince(Integer provinceId){
		
		return ApiResponse.toData(AreaHelper.getAreaByParentID(provinceId));
	}
	
	/**
	 * 根据城市ID查询区域数据
	 * @param cityId
	 * @return
	 */
	@RequestMapping("list_area")
	public @ResponseBody ApiData listArea(Integer cityId){
		
		return ApiResponse.toData(AreaHelper.getAreaByParentID(cityId));
	}
}
